package com.example.todolist.mapper;

import com.example.todolist.entity.PlanTask;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PlanTaskMapper {

    @Select("select * from planTask where userId=#{userId}")
    List<PlanTask> getAllPlanTask(Integer userId);


    @Insert("insert into planTask (userId,planTaskName,beginDate,endDate,total) VALUE(#{userId},#{planTaskName},#{beginDate},#{endDate},#{total})")
    Integer insertPlanTask(PlanTask planTask);

    @Update("update planTask set done = #{done} where userId=#{userId} AND planTaskId=#{planTaskId} ")
    Integer checkForPlanTask(Integer userId, Integer planTaskId,Integer done);

    @Select("select done from planTask where userId=#{userId} AND planTaskId=#{planTaskId}")
    Integer getDone(Integer userId,Integer planTaskId);

    @Select("select total from planTask where userId=#{userId} AND planTaskId=#{planTaskId}")
    Integer getTotal(Integer userId,Integer planTaskId);
    @Delete("delete from planTask where userId=#{userId} AND planTaskId=#{planTaskId}")
    Integer deletePlanTask(Integer userId, Integer planTaskId);
}
